<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">



<head>
<meta content="text/html; charset=utf-8" http-equiv="Content-Type" />
<title>NewsMyAdm v2</title>


<link rel="stylesheet" type="text/css" href="style.css">


</head>

<body>


<?php
session_start();

if( $_SESSION['zalogowany_admin']!="tak" )
	{
	//header('Location: ./cw_2.php'); // poprawna wersja
	echo "<meta http-equiv='refresh' content='0;url=./log.php'>";	
	exit;
	}
	



?>


<div id="exCenter">
    <div id="exHeader">
        <center><h1><a href="index.php">News system v1</a></h1></center>
    </div>
    <div id="exContent">
        <div id="exLeftColumn">
            <p>
            <center>
							

				<?PHP
				$con=mysqli_connect("localhost","root","","bd_news");
				// Check connection
				if (mysqli_connect_errno()) {
				  echo "Failed to connect to MySQL: " . mysqli_connect_error();
				}




				$result = mysqli_query($con,"SELECT id_news, title FROM `news` ");

				echo '<table>';
				
					echo '	<tr>';
						echo '	<th colspan=4>';
							echo 'Zarządzanie newsami';
						echo '	</th>'; 
					echo '	</tr>';
					
					echo '	<tr>';
						echo '	<td width="30">';
							echo 'ID';
						echo '	</td>'; 
						
						echo '	<td>';
							echo '<center>Title</center>';		
						echo '	</td>'; 
						
						echo '	<td width="30">';
							echo '<center>Upd</center>';		
						echo '	</td>'; 
						
						echo '	<td width="30">';
							echo 'Del';		
						echo '	</td>'; 
					echo '	</tr>';

					while($row = mysqli_fetch_array($result)) {

					echo '<tr>';
					echo '	<td>';
					  echo $row['id_news'];
					echo '	</td>';
					
					echo '	<td = width="690">';
					  echo  $row['title']."<br>";
					echo '	</td>';
					
					echo '	<td>';
					  echo  '<center><a href="update_news_form.php?id_update='.$row['id_news'].'"><img alt="plus" height="15" src="img/plus.png" width="15" /></a></center>';
					echo '	</td>';
					
					echo '	<td>';
					  echo  '<center><a href="del_news_mysql.php?id_del='.$row['id_news'].'"><img alt="plus" height="15" src="img/minus.png" width="15" /></a></center>';
					echo '	</td>';
					

					
					echo '</tr>';
					  
					}
				echo '</table>';
				
				echo '<FONT COLOR="white"><center><a href="add_news.php">Dodaj nowego newsa</a></center></font>';

				mysqli_close($con);	
				?>

			
			
            </p>
            
            
            
            
        </div>
        <div id="exRightColumn">
		
			
			<center><b>Quick menu:</b></center> <br><br>
			<a href="index.php">- Strona główna</a><Br>
			<a href="newsmyadm.php">- NewsMyAdm</a><Br>
			<a href="add_news.php">- Dodaj nowy news</a><br>
            <a href="logout.php">- Wyloguj</a>
            
            
            
        </div>
        <div class="exClear"></div>
    </div>
    <div id="exFooter">	    
	    <center>
	        <p><a href="newsmyadm.php">admin © 2014 Basinsky</a></p>
	    </center>    
    </div>
</div>




















</body>

</html>
